<?php
require ("include/functions.inc");
if (version_compare(PHP_VERSION,'5','>='))
 require_once('include/domxml-php4-to-php5.php');

$doc = domxml_new_xmldoc("1.0");
$doc->add_root("rss");
$root = $doc->document_element();
$root->set_attribute("version", "2.0");
$channel = $root->new_child("channel", "");
$ctl = $channel->new_child("title", "SunS");
$link = $channel->new_child("link", "http://www.sunsblog.net");
$description = $channel->new_child("description", "SunS BloG");
$pubDate = $channel->new_child("pubDate", date("D, dS of F Y h:i:s T"));
$lastBuildDate = $channel->new_child("lastBuildDate", date("D, dS of F Y h:i:s T"));
$webMaster = $channel->new_child("webMaster", "webmaster@sunsblog.net");

openConnection();
$blogQuery = "SELECT title, blogDate, content, user_id FROM sunsblogs order by blogDate desc limit 10";
$blogResult = mysql_query($blogQuery);
while (list($blogTitle, $blogDate, $content, $user_id) = mysql_fetch_row($blogResult)) {
    $item = $channel->new_child("item", "");
    $title = $item->new_child("title", $blogTitle);
    $link = $item->new_child("link", "http://www.sunsblog.net/blog.php?date=".$blogDate);
    $description = $item->new_child("description", htmlspecialchars($content));
    $pubDate = $item->new_child("pubDate", $blogDate);
 }

//print out the xml file
@header("Content-Type:text/xml");
$xml_string = $doc->dump_mem(true);
print $xml_string;
exit;
?>